{extend name="Public:base"/}

{block name="main"}

<div class="table-toolbar">
    {if condition="$order['order_status']!=0"}
    <button class="btn" disabled  >确认</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('order_status',1,'已确认');">确认</button>
    {/if}
    {if condition="$order['order_status']==3 || $order['pay_status']>=2"}
    <button class="btn" disabled>支付</button>
    {else/}
    <button class="btn btn-primary"  onclick="order_status('pay_status',2,'己完成');">支付</button>

    {/if}
    {if condition="$order['pay_status']>3 || $order['order_status']==3 || $order['shipping_status']!=0"}
    <button class="btn" disabled >发货</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('shipping_status',1,'已发货');">发货</button>
    {/if}
    {if condition="$order['pay_status']>3 || $order['order_status']==3 || $order['order_status']==2"}
    <button class="btn" disabled>完成</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('order_status',2,'己完成');">完成</button>
    {/if}
    {if condition="$order['pay_status']!=3"}
    <button class="btn" disabled >退款</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('pay_status',4,'己退款');">退款</button>
    {/if}
    {if condition="$order['pay_status']!=3"}
    <button class="btn"  disabled>退货</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('order_status',4,'己退货');">退货</button>
    {/if}
    {if condition="$order['order_status']>=2 || $order['pay_status']!=0 ||  $order['shipping_status']!=0 "}
    <button class="btn" disabled>作废</button>
    {else/}
    <button class="btn btn-primary"  onclick="order_status('order_status',3,'作废订单');">作废</button>
    {/if}
    {if condition="$order['order_status']>=2 || $order['shipping_status']!=0"}
    <button class="btn" disabled>取消</button>
    {else/}
    <button class="btn btn-primary" onclick="order_status('order_status',5,'取消订单');">取消</button>
    {/if}
    订单装态：{:L("order_status_".$order['order_status'])} | {:L("pay_status_".$order['pay_status'])} | {:L("shipping_status_".$order['shipping_status'])}
</div>

<div class="card mb-3">
    <div class="card-header">订单信息</div>
    <div class="card-body">
        <p>
            <strong>订单编号：</strong>{$order['order_sn']}
        </p>
        <p>
            <strong>创建时间：</strong>
            {$order['add_time']|toDate=###,'Y-m-d H:i:s'}
        </p>
        <p>
            <strong>支付方式：</strong>
            {$order.pay_name|default="N/A"}
        </p>
        <p>
            <strong>支付时间：</strong>
            {$order['pay_time']|toDate=###,'Y-m-d H:i:s'|default="N/A"}
        </p>

        <p>
            <strong>配送方式：</strong>
            {$order.shipping_name|default="N/A"}
            {if condition="$order['pay_status']>3 || $order['order_status']==3 || $order['shipping_status']== 0"}
            <input type="button" class="btn btn-sm btn-primary" value="修改" onclick="openwin('{:U("Order/shipping?id=".$order[id])}','配送方式','700px','550px');">
            {/if}
        </p>
        <p>
            <strong>发货时间：</strong>
            {$order['shipping_time']|toDate=###,'Y-m-d H:i:s'|default="N/A"}
        </p>
        <p>
            <strong>货单号码：</strong>
            {$order['shipping_sn']|default="N/A"}
            {lt name="order['shipping_status']" value="1"}
            <button type="button" class="btn btn-sm btn-primary" onclick="openwin('{:U('Order/shippingSn?id='.$order[id])}','货单号码','700px','550px');">{:L(edit)}</button>
            {/lt}
        <p>
        <p>
            <strong>收货时间：</strong>
            {$order['accept_time']|toDate=###,'Y-m-d H:i:s'|default="N/A"}
        </p>
    </div>

</div>

<div class="card mb-3">
    <div class="card-header">
        收货人信息
        {lt name="order['shipping_status']" value="1"}
        <a class="float-right" href="javascript:;" onclick="openwin('{:U("Order/edit?do=address&id=".$order[id]."&isajax=1")}','收货人信息','700px','550px');">修改</a>
        {/lt}
    </div>
    <div class="card-body">
        <p>
            <strong>地址：</strong>
            {$Area[$order[province]]} - {$Area[$order[city]]} - {$Area[$order[area]]} &nbsp;{$order.address}
        </p>
        <p>
            <strong>姓名：</strong>
            {$order.consignee}
        </p>
        <p>
            <strong>电话：</strong>
            {$order.tel}
        </p>
        <p>
            <strong>邮编：</strong>
            {$order.zipcode}
        </p>
        <p>
            <strong>手机：</strong>
            {$order.mobile}
        </p>
        <p>
            <strong>邮箱：</strong>
            {$order.email}
        </p>
    </div>
</div>

<div class="card mb-3">
    <div class="card-header">
        商品信息
        {if condition="1>$order['shipping_status']"}
        <a class="float-right" href="javascript:;" onclick="openwin('/?g=admin&m=Order&a=edit&do=data&id={$order[id]}&isajax=1','商品信息','700px','550px');">修改</a>
        {/if}
    </div>
    <table class="table">
        <thead>
        <tr>
            <th width="15%">商品图片</th>
            <th width="35%">商品名称</th>
            <th width="10%">单价</th>
            <th width="12%">数量</th>
            <th width="13%">小计（RMB）</th>
            <th>管理操作</th>
        </tr>
        </thead>
        {if condition="empty($order_data)"}
        <tr>
            <td colspan="6"  style="padding:10px;border:0;color:#FB0000;" align="center">{:L('Order_no_goods')}</td>
        </tr>
        {else/}
        {volist name="order_data" id="vo"}
        <tr>
            <td height="70" style="border-left:none;"><img src="{$vo['product_thumb']|thumb}" width="60" height="60"/></td>
            <td>{$vo['product_name']}</td>
            <td>{$vo['product_price']}</td>
            <td>
                {$vo['number']}
            </td>
            <td ><span class="count_price" id="count_price_{$vo['id']}">{$vo['price']|number_format=###,2}</span></td>
            <td> <a href="/home/goods/detail/id/{$vo['id']}" target="_blank">{:L('Order_view_goods')}</a></td>
        </tr>
        {/volist}
        <tr align="center">
            <td colspan="5" align="right">{:L('Order_goods_count')}：</td>
            <td><b style="color:#FB0000;font-size:14px;">{$amount|number_format=###,2}RMB</b></td>
        </tr>
        {/if}
    </table>

</div>

<div class="card">
    <div class="card-header">
        费用信息
        {if condition="1>$order['shipping_status']"}
        <a class="float-right" href="javascript:;" onclick="openwin('/?g=admin&m=Order&a=edit&do=money&id={$order[id]}&isajax=1}','费用信息','600px','350px');">修改</a>
        {/if}
    </div>
    <table class="table">
        <tr>
            <td align="right">{:L('Order_goods_amount')}：￥{$order[amount]|number_format=###,2}
                {if condition="$order[shipping_fee]>0"}+ {:L('Order_shipping_fee')}：￥{$order[shipping_fee]|number_format=###,2} {/if}
                {if condition="$order[insure_fee]>0"}+ {:L('Order_shipping_is_insure')}：￥{$order[insure_fee]|number_format=###,2} {/if}
                {if condition="$order[pay_fee]>0"}+ {:L('Order_pay_fee')}：￥{$order[pay_fee]|number_format=###,2} {/if}
                {if condition="$order[invoice_fee]>0"}+ {:L('Order_invoice_fee')}：￥{$order[invoice_fee]|number_format=###,2} <br>{/if}
                {if condition="$order[discount]!=0"}- {:L('Order_discount')}：￥{$order[discount]|number_format=###,2}{/if}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>

        </tr>
        <tr>
            <td align="right">
                <p style="font-size:16px;padding:10px 0;">
                    <strong >订单总价：</strong>
                    <b style="font-size:16px;">￥{$order[order_amount]|number_format=###,2}</b>
                    &nbsp;&nbsp;&nbsp;&nbsp;<br>
                </p>
            </td>
        </tr>
    </table>
</div>

<script>
function order_status(type,value ,msg){
    var datas={'type':type,'value':value,'dosubmit':'1'};
    layer.confirm('确定要修改订单状态?(<font color="red">'+msg+'</font>)?', {icon: 3, title:'警告'}, function(index){
        $.ajax({
            type:"POST",
            url: ROOT+"/index.php?g=Admin&m=Order&a=edit&do=status&id={$order.id}",
            data:  datas,
            timeout:"4000",
            dataType:"JSON",
            success: function(data){
                layer.msg(data.msg);
                setTimeout(function(){
                    window.location.reload();
                },2000);
            },
            error:function(){
                layer.msg(data.msg);
                return false;
            }
        });
        layer.close(index);
    });

}
</script>
{/block}